{
Author:  Prof1983 prof1983@yandex.ru
Created: 18.12.2008
LastMod: 18.12.2008
}
unit ProgressPanel;

interface

uses
  Classes, Controls, ExtCtrls, StdCtrls;

type
  TProgressPanel = class(TPanel)
  private
    Bevel1: TBevel;
    lblActivity: TLabel;
    Panel2: TPanel;
    procedure SetText(const Value: string);
    procedure SetProgressVisible(const Value: Boolean);
  public
    constructor Create(Owner: TComponent); override;
    procedure Step();
    property Text: string write SetText;
    property ProgressVisible: Boolean write SetProgressVisible;
  end;

implementation

{ TProgressPanel }

constructor TProgressPanel.Create(Owner: TComponent);
begin
  inherited;
  Parent := (Owner as TWinControl);

  Self.Width := 300;
  Self.Height := 45;
  Self.BevelOuter := bvNone;
  Self.Color := $00CCECF5;

  Bevel1 := TBevel.Create(Self);
  Bevel1.Parent := Self;
  Bevel1.Left := 7;
  Bevel1.Top := 0;
  Bevel1.Width := 250;
  Bevel1.Height := 18;

  lblActivity := TLabel.Create(Self);
  lblActivity.Parent := Self;
  lblActivity.Left := 8;
  lblActivity.Top := 20;
  lblActivity.Width := 98;
  lblActivity.Height := 13;
  lblActivity.Caption := 'Retrieving serverlist..';
  //lblActivity.Font.Charset := DEFAULT_CHARSET;
  //lblActivity.Font.Color := $00CCECF5;
  lblActivity.Font.Height := -11;
  lblActivity.Font.Name := 'MS Sans Serif';
  lblActivity.Font.Style := [];
  lblActivity.ParentFont := False;

  Panel2 := TPanel.Create(Self);
  Panel2.Parent := Self;
  Panel2.Left := 8;
  Panel2.Top := 1;
  Panel2.Width := 10;
  Panel2.Height := 16;
  Panel2.Color := 8487396;
  Panel2.TabOrder := 0;
end;

procedure TProgressPanel.SetProgressVisible(const Value: Boolean);
begin
  Bevel1.Visible := Value;
  Panel2.Visible := Value;
end;

procedure TProgressPanel.SetText(const Value: string);
begin
  lblActivity.Caption := Value;
end;

procedure TProgressPanel.Step;
begin
  if (Panel2.Tag = 0) then
  begin
    Panel2.Width := Panel2.Width+2;
    if Panel2.Width + 2 >= Bevel1.Width then
      Panel2.Tag := 1;
  end
  else
  begin
    Panel2.Left := Panel2.Left+2;
    Panel2.Width := Panel2.Width-2;
    if (Panel2.Width <= 0) then
    begin
      Panel2.Tag := 0;
      Panel2.Left := Bevel1.Left+1;
    end;
  end;
end;

end.
 